package com.boot.mgt.controller.accident

import com.boot.core.result.ResultTo
import com.boot.mgt.service.TaAccidentService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*
import javax.servlet.http.HttpServletRequest

/**
 * 事故管理接口
 */
@RestController
@RequestMapping("/app/accident")
class TaForeAccidentController {

    @Autowired
    private lateinit var accidentService: TaAccidentService

    /**
     * （重新）指派任务
     */
    @PostMapping("/assign")
    fun assign(assigned_police_number: String, accident_report_id: Int): ResultTo {
        return accidentService.assign(assigned_police_number, accident_report_id)
    }

    /**
     * 获取案件列表
     */
    @GetMapping("/accident_list")
    fun accidentList(request: HttpServletRequest,
                     page_index: Int?, page_size: Int?): ResultTo {
        val map = hashMapOf<String, Any>()
        request.parameterMap?.apply {
            for (paramMap in this) {
                map[paramMap.key] = paramMap.value[0]
            }
        }
        return accidentService.accidentList(page_index, page_size, map)
    }
}


